<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>购物车</title>
		<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css" type="text/css" />
		<script src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js" type="text/javascript"></script>
		<script src="${pageContext.request.contextPath}/js/bootstrap.min.js" type="text/javascript"></script>
		<!-- 引入自定义css文件 style.css -->
		<link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" type="text/css" />
		<style>
			body {
				margin-top: 20px;
				margin: 0 auto;
			}
			
			.carousel-inner .item img {
				width: 100%;
				height: 300px;
			}
			
			.container .row div {
				/* position:relative;
	 float:left; */
			}
			
			font {
				color: #3164af;
				font-size: 18px;
				font-weight: normal;
				padding: 0 10px;
			}
			.z{
				color: black;
			}
		</style>
	</head>

	<body background="${pageContext.request.contextPath}/img/login_bg1.jpg">

		<%@include file="header.jsp"%>

		<c:if test="${empty cart}">
			<span style="margin-left: 600px;font-size: 30px">空空如也,赶快<a href="${pageContext.request.contextPath}/index">购物</a>吧,亲😜</span>
		</c:if>

		<c:if test="${not empty cart}">
			<div class="container">
				<div class="row">

					<div style="margin:0 auto; margin-top:10px;width:950px;">
						<strong style="font-size:16px;margin:5px 0;">购物车</strong>
						<table class="table table-bordered">
							<tbody>
							<tr class="warning">
								<th>图片</th>
								<th>商品</th>
								<th>价格</th>
								<th>数量</th>
								<th>小计</th>
								<th>操作</th>
							</tr>
							<c:forEach items="${cart.items}" var="item">
								<tr class="active">
									<td width="60" width="40%">
										<input type="hidden" name="id" value="22">
										<img src="${pageContext.request.contextPath}/${item.product.pimage}" width="70" height="60">
									</td>
									<td width="30%">
										<a target="_blank">${item.product.pname}</a>
									</td>
									<td width="20%">
										￥${item.product.shop_price}
									</td>
									<td width="10%">
										<input type="text" name="quantity" readonly="readonly" value="${item.count}" maxlength="4" size="10">
									</td>
									<td width="15%">
										<span class="subtotal">￥${item.subTotal}</span>
									</td>
									<td>
										<a href="javascript:void (0);" onclick="removeCartItem('${item.product.pid}')" class="delete">删除</a>
									</td>
								</tr>
							</c:forEach>
							</tbody>
						</table>
					</div>
				</div>
				<div style="margin-right:130px;">
					<div style="text-align:right;">
						<em style="color:#ff6600;">
							登录后确认是否享有优惠&nbsp;&nbsp;
						</em> 赠送积分: <em style="color:#ff6600;">${cart.totalMoney}</em>&nbsp; 商品金额: <strong style="color:#ff6600;">￥${cart.totalMoney}元</strong>
					</div>
					<div style="text-align:right;margin-top:10px;margin-bottom:10px;">
						<a href="${pageContext.request.contextPath}/cart?methodName=clear" id="clear" class="btn btn-danger" >清空购物车</a>
						<a href="${pageContext.request.contextPath}/order?methodName=addOrder" class="btn btn-success">提交订单列表
							<%--<input type="submit" width="100" value="提交订单" name="submit" border="0" class="btn-danger" >--%>
						</a>
					</div>
				</div>

			</div>
		</c:if>


	<div  style="text-align: center;margin-top: 5px;">
		<ul class="list-inline">
			<li><a class="z">关于我们</a></li>
			<li><a class="z">联系我们</a></li>
			<li><a class="z">招贤纳士</a></li>
			<li><a class="z">法律声明</a></li>
			<li><a class="z">友情链接</a></li>
			<li><a target="_blank" class="z">支付方式</a></li>
			<li><a target="_blank" class="z">配送方式</a></li>
			<li><a class="z">服务声明</a></li>
			<li><a class="z">广告声明</a></li>
		</ul>
		<span>Copyright &copy;2020-2030  Rice mall</span>
	</div>
	</body>
<script>
	//删除购物车事件
	function removeCartItem(pid) {
		if(window.confirm("是否确认删除?")){
			window.location.href="${pageContext.request.contextPath}/cart?methodName=removeCartItemFromCart&pid="+pid;
		}
	}
</script>

</html>